/**
 * 10000 => "10,000"
 * @param {number} num
 */
export function toThousandFilter(num) {
	return (+num || 0).toString().replace(/^-?\d+/g, (m) => m.replace(/(?=(?!\b)(\d{3})+$)/g, ","));
}

/**
 * Upper case first char
 * {{ user.userName | upperCaseFirst }}
 * @param {String} string
 */
export function upperCaseFirst(string) {
	return string.charAt(0).toUpperCase() + string.slice(1);
}

/**
 * 字符串超长替换省略号
 * {{ model.name | ellipsis }}
 */
export function ellipsis(value) {
	if (!value) return "";
	if (value.length > 15) {
		return value.slice(0, 12) + "...";
	}
	return value;
}
